package org.jeecg.modules.logistics.manage.sj_info.controller;

import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import lombok.extern.slf4j.Slf4j;

import org.jeecg.modules.logistics.manage.sj_info.entity.SjInfo;
import org.jeecg.modules.logistics.manage.sj_info.service.ISjInfoService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 司机全部信息
 * @Author: 唐小尊
 * @Date: 2019-11-04
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "司机信息")
@RestController
@RequestMapping("/my/sjInfo")
public class SjInfoController {
    @Autowired
    private ISjInfoService sjInfoService;

    /**
     * 修改一个司机的状态
     *
     * @return
     */
    @AutoLog(value = "修改一个司机的状态")
    @ApiOperation(value = "修改一个司机的状态", notes = "修改一个司机的状态")
    @PutMapping(value = "/putOneUserZt")
    public Result putOneUserZt(@RequestBody JSONObject info) {
        Result<SjInfo> result = new Result<SjInfo>();
        System.out.println(info);
        //直接前端判断是什么状态
        sjInfoService.putOneUserZt(info.getString("userId"), info.getInteger("zt"));
        result.success("修改成功！");
        return result;
    }
    /**
     * 得到一个司机信息
     *
     * @return
     */
    @AutoLog(value = "得到一个司机信息")
    @ApiOperation(value = "得到一个司机信息", notes = "得到一个司机信息")
    @GetMapping(value = "/getOneSjInfo")
    public Result<SjInfo> getOneSjInfo(String sjId) {
        Result<SjInfo> result = new Result<SjInfo>();
        SjInfo hzInfo = sjInfoService.getOneSjInfo(sjId);
        result.setResult(hzInfo);
        result.success("查找成功！");
        return result;
    }

    /**
     * 得到一个司机信息
     *
     * @return
     */
    @AutoLog(value = "得到12个司机信息")
    @ApiOperation(value = "得到12个司机信息", notes = "得到12个司机信息")
    @GetMapping(value = "/getSjInfoList")
    public Result<List<SjInfo>> getSjInfoList() {
        Result<List<SjInfo>> result = new Result<List<SjInfo>>();
        List<SjInfo> sjInfos = sjInfoService.getSjInfoList();
        result.setResult(sjInfos);
        result.success("查找成功！");
        return result;
    }

}
